//
//  ListViewController.m
//  coba-iOS
//
//  Created by 郭四虎 on 15/12/9.
//  Copyright © 2015年 YouKu. All rights reserved.
//

#import "ListViewController.h"
#import "BannerModel.h"

@interface ListViewController ()<GDTMobBannerViewDelegate>
{
    NSArray *_adArr;
}
@end

@implementation ListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //self.view.backgroundColor = [UIColor lightGrayColor];
    self.scrollView.delegate = self;
}
- (GDTMobBannerView *)bannerView
{
    if (!_bannerView) {
        if (self.width) {
            _bannerView = [[GDTMobBannerView alloc] initWithFrame:CGRectMake(0, 0,
                                                                             self.width,
                                                                             GDTMOB_AD_SUGGEST_SIZE_320x50.height) appkey:GGTID placementId:@"1060712115986207"];
        }else{
            _bannerView = [[GDTMobBannerView alloc] initWithFrame:CGRectMake(0, 0,
                                                                             GDTMOB_AD_SUGGEST_SIZE_320x50.width*SCALEX,
                                                                             GDTMOB_AD_SUGGEST_SIZE_320x50.height) appkey:GGTID placementId:@"1060712115986207"];
        }
        
        
        // 设置广告视图的位置 宽与高设置为0即可 该广告视图默认是横竖屏自适应 但需要在旋转时调用orientationChanged 方法
        // Set the frame of advertisement view
        
        _bannerView.interval = 30; //【可选】设置刷新频率;默认30秒
        _bannerView.isGpsOn = NO; //【可选】开启GPS定位;默认关闭
        _bannerView.showCloseBtn = NO; //【可选】展示关闭按钮;默认显示
        _bannerView.isAnimationOn = YES; //【可选】开启banner轮播和展现时的动画效果;默认开启
        _bannerView.delegate = self;
        if (self.containedVC) {
            _bannerView.currentViewController = self.containedVC; //设置当前的ViewController
        }else{
            _bannerView.currentViewController = self;
        }
        [_bannerView loadAdAndShow];
    }
    return _bannerView;
}

- (GDTMobBannerView *)bannerView2
{
    if (!_bannerView2) {
        if (self.width) {
            _bannerView2 = [[GDTMobBannerView alloc] initWithFrame:CGRectMake(0, 0,
                                                                             self.width,
                                                                             GDTMOB_AD_SUGGEST_SIZE_320x50.height) appkey:GGTID placementId:@"1060210117104685"];
        }else{
            _bannerView2 = [[GDTMobBannerView alloc] initWithFrame:CGRectMake(0, 0,
                                                                             GDTMOB_AD_SUGGEST_SIZE_320x50.width*SCALEX,
                                                                             GDTMOB_AD_SUGGEST_SIZE_320x50.height) appkey:GGTID placementId:@"1060210117104685"];
        }
        
        
        // 设置广告视图的位置 宽与高设置为0即可 该广告视图默认是横竖屏自适应 但需要在旋转时调用orientationChanged 方法
        // Set the frame of advertisement view
        
        _bannerView2.interval = 30; //【可选】设置刷新频率;默认30秒
        _bannerView2.isGpsOn = NO; //【可选】开启GPS定位;默认关闭
        _bannerView2.showCloseBtn = NO; //【可选】展示关闭按钮;默认显示
        _bannerView2.isAnimationOn = YES; //【可选】开启banner轮播和展现时的动画效果;默认开启
        _bannerView2.delegate = self;
        
        if (self.containedVC) {
            _bannerView2.currentViewController = self.containedVC; //设置当前的ViewController
        }else{
            _bannerView2.currentViewController = self;
        }
        [_bannerView2 loadAdAndShow];
    }
    return _bannerView2;
}

- (void)createData
{

}
-(void)refresh
{

}

- (void)creatHeader
{
    
}
- (void)getContent:(NSDictionary *)response
{

}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)bannerViewMemoryWarning
{
    NSLog(@"%s",__FUNCTION__);
}

// 请求广告条数据成功后调用
//
// 详解:当接收服务器返回的广告数据成功后调用该函数
- (void)bannerViewDidReceived
{
    NSLog(@"%s",__FUNCTION__);
}

// 请求广告条数据失败后调用
//
// 详解:当接收服务器返回的广告数据失败后调用该函数
- (void)bannerViewFailToReceived:(NSError *)error
{
    NSLog(@"%s, Error:%@",__FUNCTION__,error);
    self.isFailReceive = YES;
    [[NSNotificationCenter defaultCenter]postNotificationName:@"FailToReceive" object:nil];
}

// 应用进入后台时调用
//
// 详解:当点击下载或者地图类型广告时，会调用系统程序打开，
// 应用将被自动切换到后台
- (void)bannerViewWillLeaveApplication
{
    NSLog(@"%s",__FUNCTION__);
}

// banner条曝光回调
//
// 详解:banner条曝光时回调该方法
- (void)bannerViewWillExposure
{
    
    NSLog(@"%@%s",self.title,__FUNCTION__);
}

// banner条点击回调
//
// 详解:banner条被点击时回调该方法
- (void)bannerViewClicked
{
    
    NSLog(@"%s",__FUNCTION__);
}
- (void)bannerViewWillPresentFullScreenModal
{
    NSLog(@"%s",__FUNCTION__);
}
/**
 *  banner条被用户关闭时调用
 *  详解:当打开showCloseBtn开关时，用户有可能点击关闭按钮从而把广告条关闭
 */
- (void)bannerViewWillClose
{
    NSLog(@"%s",__FUNCTION__);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
